#!/bin/bash
set -e

export TZ=UTC
export HOME=/remote/iosg/jenkins-2/bot-coin
source /remote/iosg/home/bot-coin/miniconda3/etc/profile.d/conda.sh
conda activate coin2_motion_env_migration

cd ~/jenkins/workspace/coin2_universe/coin

{% for machine in settings.keys() -%}
mkdir -p {{log_dir}}/{{trading_date}}/{{machine}}
{% endfor -%}


NUM_PARALLEL="512"
parallel -j "${NUM_PARALLEL}" --joblog fastfeed-universe-gen.log <<EOF
{% for machine in settings.keys() -%}
{% for mea in settings[machine].keys() -%}
{% for recipe in settings[machine][mea].keys() -%}
{% for (driver_settings, start, norms, job_id, proto_feed_universe_root, dest_proto_tag) in settings[machine][mea][recipe] -%}
srun --job-name {{job_id}} -N1 -n1 --cpus-per-task 1 -l --exclusive catchsegv ../fastfeed-universe-converter {% for driver_file in driver_settings -%} --driver={{driver_file}} {% endfor -%} --proto_feed_universe_root={{proto_feed_universe_root}} --dest_proto_tag={{dest_proto_tag}} --log-dir={{log_dir}} --date={{trading_date}} --start={{start}} --mea={{mea}} --recipe={{recipe}} --norm={{norms}}
{% endfor -%}
{% endfor -%}
{% endfor -%}
{% endfor -%}
EOF
